using System.Windows;
using Microsoft.Practices.CompositeUI;

namespace ApplicationShellApplication
{
	//this represents our root work item
	public sealed class RootWorkItem : WorkItem
	{
		protected override void OnRunStarted()
		{
			base.OnRunStarted();

			//here we get ObjectBuilder to build up our main window (MainWindow). Note that we removed the StartupUri from the
			//App.xaml file to ensure MainWindow isn't created by WPF automatically (we want to use ObjectBuilder to get correct
			//dependency injection behavior etc)
			MainWindow mainWindow = Items.AddNew<MainWindow>();

			//here we ensure that the WPF application is configured to shut down when mainWindow is closed (you may like to change
			//this behavior in your application)
			Application.Current.MainWindow = mainWindow;
			Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

			//show the main window
			mainWindow.Show();
		}
	}
}
